<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *公告管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'sj';
if($_RQ['op']=='sj'){
	$item=$this->plugin_setting('poster2_'.$merchid);
	$data=$this->goodsdatademo;
	$item['url']=custom_url('jy_merch2fee/build//type=3',true);
	$item['data']['image']=$item['data']['image']?:'../addons/jy_poster/resource/images/bg.jpg';
	$item['data']['data']=$item['data']['data']?:$data;
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'edit',
		'post'=>'design',
		'desc'=>'团二维码海报',
		'edit'=>array(
			array('type'=>'switch','name'=>'isopen','title'=>'启用二维码海报？'),
			array('type'=>'post','name'=>'qc','action'=>'qc','message'=>'确定清空缓存？','title'=>'清楚海报缓存？'),
			array('type'=>'poster','name'=>'data','datademo'=>'datademo','datatypes'=>'datatypes','datapushs'=>'datapushs','title'=>'',),
		),
	);
	$return['datademo']=array('data'=>$data,'image'=>'../addons/jy_poster/resource/images/bg.jpg');
	$return['datatypes']=$this->datatypes;
	$return['datapushs']=$this->datapushs;
	exi($return);
}
if($_RQ['op']=='qc'){
	$typename='jy_merch2fee';
	$path=ROOT_AT .'/images/jy_poster/' . $_SESSION['uniacid'].'/'.$typename.'/';
	$handle = scandir($path);
	foreach($handle as $val){
    	//排除目录中的.和..
    	if($val !="." && $val !=".."){
    		//如果是文件直接删除
    		unlink($path.$val);
		}
   }
   $like='oss/' . $_SESSION['uniacid'].'/images/jy_poster/'.$typename.'/';
   pdo_delete('core_attachment',array('attachment like'=>'%'.trim($like).'%','uniacid'=>$_SESSION['uniacid']));
   exi('清除成功','','sj');
}

if($_RQ['op']=='design'){
	$postdata=get_postdata();
	$this->plugin_setting('poster2_'.$merchid,$postdata);
	exi('设置成功');
}
